//
//  DTabBarViewController.m
//  JuBao
//
//  Created by apple on 2017/8/23.
//  Copyright © 2017年 李肖飞. All rights reserved.
//

#import "DTabBarViewController.h"
#import "OneViewController.h"
#import "TwoViewController.h"
#import "ThreeViewController.h"
#import "FourViewController.h"
#import "CommonUtils.h"

@interface DTabBarViewController ()

@end

@implementation DTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadViewControllers];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}



- (void)loadViewControllers {
    
    // 第一页
    OneViewController *mainVC = [[OneViewController alloc] init];
    UINavigationController *mainNC = [[UINavigationController alloc] initWithRootViewController:mainVC];
    UITabBarItem *mainTabBarItem =[[UITabBarItem alloc] initWithTitle:@"首页" image:[UIImage imageNamed:@"bar-home-nor"] selectedImage:[UIImage imageNamed:@"bar-home-sel"]];
    mainNC.tabBarItem = mainTabBarItem;
    
    // 第二页
    TwoViewController *agentVC = [[TwoViewController alloc] init];
    UINavigationController *agentNC = [[UINavigationController alloc] initWithRootViewController:agentVC];
//    agentNC = [[UINavigationController alloc] initWithRootViewController:agentVC];
    UITabBarItem *agentTabBarItem = [[UITabBarItem alloc] initWithTitle:@"须知" image:[UIImage imageNamed:@"bar-notice-nor"] selectedImage:[UIImage imageNamed:@"bar-notice-sel"]];
    agentNC.tabBarItem = agentTabBarItem;
    
    // 第三页
    ThreeViewController *userVC = [[ThreeViewController alloc] init];
    UINavigationController *userNC = [[UINavigationController alloc] initWithRootViewController:userVC];
    UITabBarItem *userTabBarItem = [[UITabBarItem alloc] initWithTitle:@"申请" image:[UIImage imageNamed:@"bar-apply-nor"] selectedImage:[UIImage imageNamed:@"bar-apply-sel"]];
    userNC.tabBarItem = userTabBarItem;
    
    // 第四页
    FourViewController *fourVC = [[FourViewController alloc] init];
    UINavigationController *fourNC = [[UINavigationController alloc] initWithRootViewController:fourVC];
    UITabBarItem *fourTabBarItem = [[UITabBarItem alloc] initWithTitle:@"后台" image:[UIImage imageNamed:@"bar-bac-nor"] selectedImage:[UIImage imageNamed:@"bar-bac-sel"]];
    fourNC.tabBarItem = fourTabBarItem;
    
    NSArray *controllersArray = @[mainNC, agentNC, userNC, fourNC];
    // 6.把导航控制器的数组加入到标签控制器
    [self setViewControllers:controllersArray animated:YES];
    [self.tabBar setTintColor:[UIColor colorWithRGB:color_MinGreen]];
    [self.tabBar setBackgroundColor:[UIColor colorWithRGB:color_ee]];
    self.tabBar.translucent = NO;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
